<!DOCTYPE html>
<html>
{include file="users/public_layout" /}
<link rel="stylesheet" type="text/css" href="{eju:global name='web_templets_mobile' /}/skin/css/login.css">
<body>
<div class="layadmin-user-login layadmin-user-display-show" id="LAY-user-login" style="display: none;">
    <div class="layadmin-user-login-main">
        <div class="layadmin-user-login-box layadmin-user-login-header">
            <!-- <div style="margin-bottom: 10px;"><img height="34" src="__PUBLIC__/static/admin/images/logo_login.png" alt=""></div> -->
            <p>易居房产系统会员中心</p>
        </div>
        <div class="layadmin-user-login-box layadmin-user-login-body layui-form">
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-mobile" ></label>
                <input type="text" value="{$users.mobile|default=''}"  disabled="true" placeholder="登陆账号" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="password"></label>
                <input type="password" name="password" id="password" lay-verify="check_password" placeholder="新密码" class="layui-input">
            </div>
            <div class="layui-form-item">
                <label class="layadmin-user-login-icon layui-icon layui-icon-password" for="verify_password"></label>
                <input type="password" name="verify_password" id="verify_password" lay-verify="required" placeholder="确认新密码" class="layui-input">
            </div>
            <div class="layui-form-item">
                <button class="layui-btn layui-btn-fluid" lay-submit lay-filter="formSubmit">确认提交</button>
            </div>

        </div>
    </div>
</div>

<script>
    layui.config({
        base: '__SKIN__/' //静态资源所在路径
        ,version: '{$version}'
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'user'], function(){
        var $ = layui.$
            ,setter = layui.setter
            ,admin = layui.admin
            ,form = layui.form
            ,router = layui.router();

        form.render();
        form.verify({
            check_password:function (value, item) {
                if(value == '' || undefined == value){
                    return '请填写密码！';
                }
                if (value.length < 6){
                    return '密码不能少于6位！';
                }
                var verify_password = $("#verify_password").val();
                if (value !== verify_password){
                    return '两次输入密码不一致！';
                }
            }
        });

        //提交
        form.on('submit(formSubmit)', function(data){
            var load = layer_loading();
            //确认密码
            if(data.field.password !== data.field.verify_password){
                return layer.msg('两次密码输入不一致');
            }
            //请求接口
            data.field._ajax = 1;
            $.ajax({
                type : 'post',
                url : "{:url('Users/reset_password')}",
                data : data.field,
                dataType : 'json',
                success : function(res){
                    layer.close(load); //关闭loading
                    if (1 == res.code) {
                        layer.msg(res.msg, {time: 1500}, function(){
                            window.location.href = res.url;
                        });
                    } else {
                        layer.msg(res.msg, {icon: 5, title:false});
                        return false;
                    }
                },
                error: function(e){
                    layer.close(load); //关闭loading
                    showErrorAlert();
                }
            });

            return false;
        });
    });
    function countdown(){
        // 倒计时
        var setTime;
        var time = {php}echo config('global.email_send_time');{/php};
        setTime = setInterval(function(){
            if(0 >= time){
                clearInterval(setTime);
                return;
            }
            time--;
            $("#email_code_button").val(time+'秒');
            $("#email_code_button").attr('disabled', 'disabled');

            if(time == 0){
                $("#email_code_button").val('点击发送');
                $("#email_code_button").removeAttr("disabled");
            }
        },1000);
    }
</script>
</body>
</html>